#include "Interactiv_BIM/Interactiv_BIMPublic.h"

#include "Datas/DatasPublic.h"


TiJiaoXianCommand::TiJiaoXianCommand(Interactiv_Base* bim_Interactiv, int type) : ChaiDanCommand(bim_Interactiv, type)
{

}

bool Interactiv_BIM_::TiJiaoXianCommand::commandEnd()
{
	OcDbObjectIdMap cabinets;
	g_ChaiDanDataBase->GetKeyMap(CDatePuTongGui::m_sDataType, cabinets);
	if (!cabinets.size())
		return false;

	osg::BoundingBox box;
	OSGChaiDanTool::searchRectangularArea(m_release_point, m_push_point, box);
	CDatePuTongGui *cabinet = (CDatePuTongGui *)cabinets.begin()->first.data();
	osg::Vec3f cntr = box.getBehindRectPlane().centerPoint() + osg::Vec3f(0, 0, cabinet->mBox.mDepth) * 0.5;
	osg::BoundingBox realBox(cntr, box.mWidth, box.mHeight, cabinet->mBox.mDepth);

	CDateTiJiaoXian tijiaoxian;
	CDateHorGeBan geban;
	// SimpleAlgorithTool::GeneratorBaseboardByArea(tijiaoxian, realBox, true, &geban);
	tijiaoxian.GeneratorByArea(realBox, &geban);
	ChaiDanDataBase::AddData(&geban);
	ChaiDanDataBase::AddData(&tijiaoxian);
	ChaiDanDataBase::CommitData();

	state_ = 0;
	return true;
}
